.class public Lcom/android/deskclock/AlarmReceiver;
.super Landroid/content/BroadcastReceiver;
.source "AlarmReceiver.java"


# static fields
.field private static final STALE_WINDOW:I = 0x708


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 37
    invoke-direct {p0}, Landroid/content/BroadcastReceiver;-><init>()V

    return-void
.end method

.method private getNotificationManager(Landroid/content/Context;)Landroid/app/NotificationManager;
    .locals 1
    .parameter "context"

    .prologue
    .line 157
    const-string v0, "notification"

    invoke-virtual {p1, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object p0

    .end local p0
    check-cast p0, Landroid/app/NotificationManager;

    return-object p0
.end method

.method private updateNotification(Landroid/content/Context;Lcom/android/deskclock/Alarm;I)V
    .locals 9
    .parameter "context"
    .parameter "alarm"
    .parameter "timeout"

    .prologue
    const/4 v8, 0x0

    .line 162
    invoke-direct {p0, p1}, Lcom/android/deskclock/AlarmReceiver;->getNotificationManager(Landroid/content/Context;)Landroid/app/NotificationManager;

    move-result-object v3

    .line 165
    .local v3, nm:Landroid/app/NotificationManager;
    if-nez p2, :cond_0

    .line 192
    :goto_0
    return-void

    .line 173
    :cond_0
    new-instance v4, Landroid/content/Intent;

    const-class v5, Lcom/android/deskclock/SetAlarm;

    invoke-direct {v4, p1, v5}, Landroid/content/Intent;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    .line 174
    .local v4, viewAlarm:Landroid/content/Intent;
    const-string v5, "alarm_id"

    iget v6, p2, Lcom/android/deskclock/Alarm;->id:I

    invoke-virtual {v4, v5, v6}, Landroid/content/Intent;->putExtra(Ljava/lang/String;I)Landroid/content/Intent;

    .line 175
    iget v5, p2, Lcom/android/deskclock/Alarm;->id:I

    invoke-static {p1, v5, v4, v8}, Landroid/app/PendingIntent;->getActivity(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;

    move-result-object v0

    .line 180
    .local v0, intent:Landroid/app/PendingIntent;
    invoke-virtual {p2, p1}, Lcom/android/deskclock/Alarm;->getLabelOrDefault(Landroid/content/Context;)Ljava/lang/String;

    move-result-object v1

    .line 181
    .local v1, label:Ljava/lang/String;
    new-instance v2, Landroid/app/Notification;

    const v5, 0x7f020034

    iget-wide v6, p2, Lcom/android/deskclock/Alarm;->time:J

    invoke-direct {v2, v5, v1, v6, v7}, Landroid/app/Notification;-><init>(ILjava/lang/CharSequence;J)V

    .line 183
    .local v2, n:Landroid/app/Notification;
    const v5, 0x7f080014

    const/4 v6, 0x1

    new-array v6, v6, [Ljava/lang/Object;

    invoke-static {p3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v7

    aput-object v7, v6, v8

    invoke-virtual {p1, v5, v6}, Landroid/content/Context;->getString(I[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v2, p1, v1, v5, v0}, Landroid/app/Notification;->setLatestEventInfo(Landroid/content/Context;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Landroid/app/PendingIntent;)V

    .line 186
    iget v5, v2, Landroid/app/Notification;->flags:I

    or-int/lit8 v5, v5, 0x10

    iput v5, v2, Landroid/app/Notification;->flags:I

    .line 190
    iget v5, p2, Lcom/android/deskclock/Alarm;->id:I

    invoke-virtual {v3, v5}, Landroid/app/NotificationManager;->cancel(I)V

    .line 191
    iget v5, p2, Lcom/android/deskclock/Alarm;->id:I

    invoke-virtual {v3, v5, v2}, Landroid/app/NotificationManager;->notify(ILandroid/app/Notification;)V

    goto :goto_0
.end method


# virtual methods
.method public onReceive(Landroid/content/Context;Landroid/content/Intent;)V
    .locals 25
    .parameter "context"
    .parameter "intent"

    .prologue
    .line 45
    const-string v21, "alarm_killed"

    invoke-virtual/range {p2 .. p2}, Landroid/content/Intent;->getAction()Ljava/lang/String;

    move-result-object v22

    invoke-virtual/range {v21 .. v22}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v21

    if-eqz v21, :cond_1

    .line 47
    const-string v21, "intent.extra.alarm"

    move-object/from16 v0, p2

    move-object/from16 v1, v21

    invoke-virtual {v0, v1}, Landroid/content/Intent;->getParcelableExtra(Ljava/lang/String;)Landroid/os/Parcelable;

    move-result-object v5

    check-cast v5, Lcom/android/deskclock/Alarm;

    const-string v21, "alarm_killed_timeout"

    const/16 v22, -0x1

    move-object/from16 v0, p2

    move-object/from16 v1, v21

    move/from16 v2, v22

    invoke-virtual {v0, v1, v2}, Landroid/content/Intent;->getIntExtra(Ljava/lang/String;I)I

    move-result v21

    move-object/from16 v0, p0

    move-object/from16 v1, p1

    move-object v2, v5

    move/from16 v3, v21

    invoke-direct {v0, v1, v2, v3}, Lcom/android/deskclock/AlarmReceiver;->updateNotification(Landroid/content/Context;Lcom/android/deskclock/Alarm;I)V

    .line 154
    :cond_0
    :goto_0
    return-void

    .line 51
    :cond_1
    const-string v21, "cancel_snooze"

    invoke-virtual/range {p2 .. p2}, Landroid/content/Intent;->getAction()Ljava/lang/String;

    move-result-object v22

    invoke-virtual/range {v21 .. v22}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v21

    if-eqz v21, :cond_2

    .line 52
    const/16 v21, -0x1

    const-wide/16 v22, -0x1

    move-object/from16 v0, p1

    move/from16 v1, v21

    move-wide/from16 v2, v22

    invoke-static {v0, v1, v2, v3}, Lcom/android/deskclock/Alarms;->saveSnoozeAlert(Landroid/content/Context;IJ)V

    goto :goto_0

    .line 56
    :cond_2
    const/4 v5, 0x0

    .line 61
    .local v5, alarm:Lcom/android/deskclock/Alarm;
    const-string v21, "intent.extra.alarm_raw"

    move-object/from16 v0, p2

    move-object/from16 v1, v21

    invoke-virtual {v0, v1}, Landroid/content/Intent;->getByteArrayExtra(Ljava/lang/String;)[B

    move-result-object v9

    .line 62
    .local v9, data:[B
    if-eqz v9, :cond_3

    .line 63
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v11

    .line 64
    .local v11, in:Landroid/os/Parcel;
    const/16 v21, 0x0

    move-object v0, v9

    array-length v0, v0

    move/from16 v22, v0

    move-object v0, v11

    move-object v1, v9

    move/from16 v2, v21

    move/from16 v3, v22

    invoke-virtual {v0, v1, v2, v3}, Landroid/os/Parcel;->unmarshall([BII)V

    .line 65
    const/16 v21, 0x0

    move-object v0, v11

    move/from16 v1, v21

    invoke-virtual {v0, v1}, Landroid/os/Parcel;->setDataPosition(I)V

    .line 66
    sget-object v21, Lcom/android/deskclock/Alarm;->CREATOR:Landroid/os/Parcelable$Creator;

    move-object/from16 v0, v21

    move-object v1, v11

    invoke-interface {v0, v1}, Landroid/os/Parcelable$Creator;->createFromParcel(Landroid/os/Parcel;)Ljava/lang/Object;

    move-result-object v5

    .end local v5           #alarm:Lcom/android/deskclock/Alarm;
    check-cast v5, Lcom/android/deskclock/Alarm;

    .line 69
    .end local v11           #in:Landroid/os/Parcel;
    .restart local v5       #alarm:Lcom/android/deskclock/Alarm;
    :cond_3
    if-nez v5, :cond_4

    .line 70
    const-string v21, "AlarmReceiver failed to parse the alarm from the intent"

    invoke-static/range {v21 .. v21}, Lcom/android/deskclock/Log;->v(Ljava/lang/String;)V

    goto :goto_0

    .line 76
    :cond_4
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v17

    .line 77
    .local v17, now:J
    new-instance v10, Ljava/text/SimpleDateFormat;

    const-string v21, "HH:mm:ss.SSS aaa"

    move-object v0, v10

    move-object/from16 v1, v21

    invoke-direct {v0, v1}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;)V

    .line 79
    .local v10, format:Ljava/text/SimpleDateFormat;
    new-instance v21, Ljava/lang/StringBuilder;

    invoke-direct/range {v21 .. v21}, Ljava/lang/StringBuilder;-><init>()V

    const-string v22, "AlarmReceiver.onReceive() id "

    invoke-virtual/range {v21 .. v22}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v21

    move-object v0, v5

    iget v0, v0, Lcom/android/deskclock/Alarm;->id:I

    move/from16 v22, v0

    invoke-virtual/range {v21 .. v22}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v21

    const-string v22, " setFor "

    invoke-virtual/range {v21 .. v22}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v21

    new-instance v22, Ljava/util/Date;

    move-object v0, v5

    iget-wide v0, v0, Lcom/android/deskclock/Alarm;->time:J

    move-wide/from16 v23, v0

    invoke-direct/range {v22 .. v24}, Ljava/util/Date;-><init>(J)V

    move-object v0, v10

    move-object/from16 v1, v22

    invoke-virtual {v0, v1}, Ljava/text/SimpleDateFormat;->format(Ljava/util/Date;)Ljava/lang/String;

    move-result-object v22

    invoke-virtual/range {v21 .. v22}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v21

    invoke-virtual/range {v21 .. v21}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v21

    invoke-static/range {v21 .. v21}, Lcom/android/deskclock/Log;->v(Ljava/lang/String;)V

    .line 82
    move-object v0, v5

    iget-wide v0, v0, Lcom/android/deskclock/Alarm;->time:J

    move-wide/from16 v21, v0

    const-wide/32 v23, 0x1b7740

    add-long v21, v21, v23

    cmp-long v21, v17, v21

    if-gtz v21, :cond_0

    .line 91
    invoke-static/range {p1 .. p1}, Lcom/android/deskclock/AlarmAlertWakeLock;->acquireCpuWakeLock(Landroid/content/Context;)V

    .line 94
    new-instance v8, Landroid/content/Intent;

    const-string v21, "android.intent.action.CLOSE_SYSTEM_DIALOGS"

    move-object v0, v8

    move-object/from16 v1, v21

    invoke-direct {v0, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 95
    .local v8, closeDialogs:Landroid/content/Intent;
    move-object/from16 v0, p1

    move-object v1, v8

    invoke-virtual {v0, v1}, Landroid/content/Context;->sendBroadcast(Landroid/content/Intent;)V

    .line 98
    const-class v7, Lcom/android/deskclock/AlarmAlert;

    .line 99
    .local v7, c:Ljava/lang/Class;
    const-string v21, "keyguard"

    move-object/from16 v0, p1

    move-object/from16 v1, v21

    invoke-virtual {v0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v12

    check-cast v12, Landroid/app/KeyguardManager;

    .line 101
    .local v12, km:Landroid/app/KeyguardManager;
    invoke-virtual {v12}, Landroid/app/KeyguardManager;->inKeyguardRestrictedInputMode()Z

    move-result v21

    if-eqz v21, :cond_5

    .line 103
    const-class v7, Lcom/android/deskclock/AlarmAlertFullScreen;

    .line 108
    :cond_5
    new-instance v6, Landroid/content/Intent;

    move-object v0, v6

    move-object/from16 v1, p1

    move-object v2, v7

    invoke-direct {v0, v1, v2}, Landroid/content/Intent;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    .line 109
    .local v6, alarmAlert:Landroid/content/Intent;
    const-string v21, "intent.extra.alarm"

    move-object v0, v6

    move-object/from16 v1, v21

    move-object v2, v5

    invoke-virtual {v0, v1, v2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Landroid/os/Parcelable;)Landroid/content/Intent;

    .line 110
    const/high16 v21, 0x1004

    move-object v0, v6

    move/from16 v1, v21

    invoke-virtual {v0, v1}, Landroid/content/Intent;->setFlags(I)Landroid/content/Intent;

    .line 112
    move-object/from16 v0, p1

    move-object v1, v6

    invoke-virtual {v0, v1}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V

    .line 115
    move-object v0, v5

    iget v0, v0, Lcom/android/deskclock/Alarm;->id:I

    move/from16 v21, v0

    move-object/from16 v0, p1

    move/from16 v1, v21

    invoke-static {v0, v1}, Lcom/android/deskclock/Alarms;->disableSnoozeAlert(Landroid/content/Context;I)V

    .line 117
    move-object v0, v5

    iget-object v0, v0, Lcom/android/deskclock/Alarm;->daysOfWeek:Lcom/android/deskclock/Alarm$DaysOfWeek;

    move-object/from16 v21, v0

    invoke-virtual/range {v21 .. v21}, Lcom/android/deskclock/Alarm$DaysOfWeek;->isRepeatSet()Z

    move-result v21

    if-nez v21, :cond_6

    .line 118
    move-object v0, v5

    iget v0, v0, Lcom/android/deskclock/Alarm;->id:I

    move/from16 v21, v0

    const/16 v22, 0x0

    move-object/from16 v0, p1

    move/from16 v1, v21

    move/from16 v2, v22

    invoke-static {v0, v1, v2}, Lcom/android/deskclock/Alarms;->enableAlarm(Landroid/content/Context;IZ)V

    .line 126
    :goto_1
    new-instance v20, Landroid/content/Intent;

    const-string v21, "com.android.deskclock.ALARM_ALERT"

    invoke-direct/range {v20 .. v21}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 127
    .local v20, playAlarm:Landroid/content/Intent;
    const-string v21, "intent.extra.alarm"

    move-object/from16 v0, v20

    move-object/from16 v1, v21

    move-object v2, v5

    invoke-virtual {v0, v1, v2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Landroid/os/Parcelable;)Landroid/content/Intent;

    .line 128
    move-object/from16 v0, p1

    move-object/from16 v1, v20

    invoke-virtual {v0, v1}, Landroid/content/Context;->startService(Landroid/content/Intent;)Landroid/content/ComponentName;

    .line 133
    new-instance v16, Landroid/content/Intent;

    const-class v21, Lcom/android/deskclock/AlarmAlert;

    move-object/from16 v0, v16

    move-object/from16 v1, p1

    move-object/from16 v2, v21

    invoke-direct {v0, v1, v2}, Landroid/content/Intent;-><init>(Landroid/content/Context;Ljava/lang/Class;)V

    .line 134
    .local v16, notify:Landroid/content/Intent;
    const-string v21, "intent.extra.alarm"

    move-object/from16 v0, v16

    move-object/from16 v1, v21

    move-object v2, v5

    invoke-virtual {v0, v1, v2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Landroid/os/Parcelable;)Landroid/content/Intent;

    .line 135
    move-object v0, v5

    iget v0, v0, Lcom/android/deskclock/Alarm;->id:I

    move/from16 v21, v0

    const/16 v22, 0x0

    move-object/from16 v0, p1

    move/from16 v1, v21

    move-object/from16 v2, v16

    move/from16 v3, v22

    invoke-static {v0, v1, v2, v3}, Landroid/app/PendingIntent;->getActivity(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;

    move-result-object v19

    .line 140
    .local v19, pendingNotify:Landroid/app/PendingIntent;
    move-object v0, v5

    move-object/from16 v1, p1

    invoke-virtual {v0, v1}, Lcom/android/deskclock/Alarm;->getLabelOrDefault(Landroid/content/Context;)Ljava/lang/String;

    move-result-object v13

    .line 141
    .local v13, label:Ljava/lang/String;
    new-instance v14, Landroid/app/Notification;

    const v21, 0x7f020034

    move-object v0, v5

    iget-wide v0, v0, Lcom/android/deskclock/Alarm;->time:J

    move-wide/from16 v22, v0

    move-object v0, v14

    move/from16 v1, v21

    move-object v2, v13

    move-wide/from16 v3, v22

    invoke-direct {v0, v1, v2, v3, v4}, Landroid/app/Notification;-><init>(ILjava/lang/CharSequence;J)V

    .line 143
    .local v14, n:Landroid/app/Notification;
    const v21, 0x7f08002f

    move-object/from16 v0, p1

    move/from16 v1, v21

    invoke-virtual {v0, v1}, Landroid/content/Context;->getString(I)Ljava/lang/String;

    move-result-object v21

    move-object v0, v14

    move-object/from16 v1, p1

    move-object v2, v13

    move-object/from16 v3, v21

    move-object/from16 v4, v19

    invoke-virtual {v0, v1, v2, v3, v4}, Landroid/app/Notification;->setLatestEventInfo(Landroid/content/Context;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Landroid/app/PendingIntent;)V

    .line 146
    move-object v0, v14

    iget v0, v0, Landroid/app/Notification;->flags:I

    move/from16 v21, v0

    or-int/lit8 v21, v21, 0x3

    move/from16 v0, v21

    move-object v1, v14

    iput v0, v1, Landroid/app/Notification;->flags:I

    .line 148
    move-object v0, v14

    iget v0, v0, Landroid/app/Notification;->defaults:I

    move/from16 v21, v0

    or-int/lit8 v21, v21, 0x4

    move/from16 v0, v21

    move-object v1, v14

    iput v0, v1, Landroid/app/Notification;->defaults:I

    .line 152
    invoke-direct/range {p0 .. p1}, Lcom/android/deskclock/AlarmReceiver;->getNotificationManager(Landroid/content/Context;)Landroid/app/NotificationManager;

    move-result-object v15

    .line 153
    .local v15, nm:Landroid/app/NotificationManager;
    move-object v0, v5

    iget v0, v0, Lcom/android/deskclock/Alarm;->id:I

    move/from16 v21, v0

    move-object v0, v15

    move/from16 v1, v21

    move-object v2, v14

    invoke-virtual {v0, v1, v2}, Landroid/app/NotificationManager;->notify(ILandroid/app/Notification;)V

    goto/16 :goto_0

    .line 122
    .end local v13           #label:Ljava/lang/String;
    .end local v14           #n:Landroid/app/Notification;
    .end local v15           #nm:Landroid/app/NotificationManager;
    .end local v16           #notify:Landroid/content/Intent;
    .end local v19           #pendingNotify:Landroid/app/PendingIntent;
    .end local v20           #playAlarm:Landroid/content/Intent;
    :cond_6
    invoke-static/range {p1 .. p1}, Lcom/android/deskclock/Alarms;->setNextAlert(Landroid/content/Context;)V

    goto/16 :goto_1
.end method
